package com.leihao.product.service.impl;

import com.leihao.product.domian.ProductFullReduction;
import com.leihao.product.mapper.ProductFullReductionMapper;
import com.leihao.product.service.ProductFullReductionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class ProductFullReductionServiceImpl implements ProductFullReductionService {
@Autowired
    private ProductFullReductionMapper productFullReductionMapper;

    @Override
    public void addBatch(List<ProductFullReduction> list) {
        if (CollectionUtils.isEmpty(list)){
            throw new RuntimeException("商品满减信息不能为空");
        }
        productFullReductionMapper.addBatch(list);
    }

    @Override
    public void update(ProductFullReduction productFullReduction) {
        if (productFullReduction == null){
            throw new RuntimeException("商品满减信息不能为空");
        }
        if (productFullReduction.getProductFullReductionId() == null){
            throw new RuntimeException("商品满减信息ID不能为空");
        }
        productFullReductionMapper.update(productFullReduction);
    }

    @Override
    public void deleteFullReductionList(Integer productId) {
        if (productId == null){
            throw new RuntimeException("商品ID不能为空");
        }
        productFullReductionMapper.deleteFullReductionList(productId);
    }


}
